package edu.hunau.cxb19.oop.class30;

import org.junit.Test;

/**
 *
 * @author hb
 *
 *         2020-04-14 15:11:10
 */
public class ThreadJoinTest {

	
	public static  void main(String[] args) {
		Thread t1 = new Thread(() -> {
			for (int i = 0; i < 100; i++) {
				System.out.println("\t " + Thread.currentThread().getName() +" :i=" + i);
			}
		}, "my-thread-A");

		Thread t2 = new Thread(() -> {
			for (int i = 0; i < 100; i++) {
				if(i==30) {
					try {
						t1.join();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				System.out.println(
						Thread.currentThread().getName() +  " i=" + i);
			}
		}, "my-thread-B");
 

		t1.start();
		t2.start();
	}
}
